<template>
	<view>
	<form @submit="formSubmit" @reset="formReset">
		<view class="content">
			<label class="lable">电炉铁水成分标准碳</label>
			<text  class="v_input">{{dlcftzssbz.cCfbz}}</text>
		</view>
		
		<view class="content">
			<label class="lable">电炉铁水成分标准硅</label>
			<text class="v_input">{{dlcftzssbz.siCfbz}}</text>
		</view>
		
		
	<!--	< view class="content">
			<label class="lable">增碳剂碳含量</label>
			<text class="v_input">{{dlcftzssbz.ztjCHl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">增碳剂碳吸收率</label>
			<text class="v_input">{{dlcftzssbz.ztjCXsl}}</text>
		</view>
		<view class="content">
			<label class="lable">硅粒硅含量</label>
			<text class="v_input">{{dlcftzssbz.glSiHl}}</text>
		</view>
		
		<view class="content">
			<label class="lable">硅粒硅吸收率</label>
			<text class="v_input">{{dlcftzssbz.glSiXsl}}</text>
		</view> -->
		
		
		
		
		
		<view class="content">
			<label class="lable">铁水检测C%:</label>
			<input type="number" name="jcc"  class="v_input"  placeholder="请输入" />
		</view>
		
		<view class="content">
			<label class="lable">铁水检测Si%:</label>
			<input type="number" name="si"  class="v_input"  placeholder="请输入" />
		</view>
	
		
		<view class="content">
			<label class="lable">电炉配料总重量(kg):</label>
			<input type="number" name="plzz"  class="v_input"  placeholder="请输入"/>
		</view>
		
		<view class="break-space"></view>
		<view class="content">
			<label class="lable">增碳剂补加量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{ztj}}</label>
		</view>
		<view class="content">
			<label class="lable">硅粒补加量(kg):</label>
			<label class="result" :style="{ color: textColor }">{{gl}}</label>
		</view>
		<button form-type="submit" class="btn">计算</button>
	</form>
		
	</view>
</template>

<script>
	import configService from '@/common/config.service.js';
	const apiUrl = configService.apiUrl;
	export default {
		data() {
			return {
				dlcftzssbz : null,
				ztj : 0,
				gl : 0,
				mt : 0,
				sht : 0,
				textColor:'black'
			}
		},
		onLoad() {
			this.getCftzBz();
		},
		onShow:function(e){
			this.$verify.verify();
		},
		methods: {
			getCftzBz(){
				uni.request({
					url:apiUrl+'/dlcftzss/list',
					header:{
						'content-type':'application/json'
					},
					method:'POST',
					data:{
						deptId:uni.getStorageSync("deptId"),type: 2
					},
					success: (res) => {
						if(res.statusCode === 200 &&  res.data.data.length > 0 )
						{
							this.dlcftzssbz = res.data.data[0];
						}else{
							uni.showModal({
							    title: '提示',  //提示标题
							    content: '请维护电路成分调整速算标准！',  //提示内容
							    showCancel: true, //是否显示取消按钮
							    success: function (res) {
							        if (res.confirm) {  //confirm为ture，代表用户点击确定
							            console.log('点击了确定按钮');
							        } else if (res.cancel) {  //cancel为ture，代表用户点击取消
							            console.log('点击了取消按钮');
							        }
							    }
							})
						}
					}
				})
			},
			formSubmit(e) {
				var _this = this;
				if(_this.dlcftzssbz == null){
					uni.showToast({
						title: "请维护电路成分调整速算标准！",
						icon:'error',
						duration:1000
					});
					return ;
				}
				let formData = e.detail.value;
				// 标准碳含量
				let bzchl = formData.plzz*this.dlcftzssbz.cCfbz;
				// 现有碳含量
				let xythl = formData.plzz*formData.jcc;
				// 增碳剂理论加入量
				this.ztj = ((bzchl-xythl)/this.dlcftzssbz.ztjCHl/this.dlcftzssbz.ztjCXsl*100).toFixed(2)
				// 标准硅含量
				let bzsihl = formData.plzz*this.dlcftzssbz.siCfbz;
				// 现有硅含量
				let xysihl = formData.plzz*formData.si;
				// 硅铁粒理论加入量
				this.gl = ((bzsihl-xysihl)/this.dlcftzssbz.glSiHl/this.dlcftzssbz.glSiXsl*100).toFixed(2)
				this.textColor = '#3E60D2';		
			}
		}
	}
</script>

<style>
	@import "@/common/susuanqt.css";
</style>
